package com.tongfusoft.document.system.notice.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.tongfuosft.document.system.notice.service.INoticeService;
import com.tongfusoft.da.pagehelper.PageInfo;
import com.tongfusoft.da.template.service.impl.DataTemplateServiceImpl;
import com.tongfusoft.document.entity.Docs;
import com.tongfusoft.document.entity.Notice;
import com.tongfusoft.document.entity.Users;
import com.tongfusoft.utils.UIDGeneratorService;

@Service("noticeService")
public class NoticeServiceImpl extends DataTemplateServiceImpl implements
		INoticeService {

	@Override
	public void createNotice(Notice notice,Users user) {
		notice.setNoticeId(UIDGeneratorService.getUUID());
		notice.setInfoType("关注");
		notice.setNoticeInfo("文档已更新");
		notice.setNoticeIsread("1");
		notice.setTitle("");
		notice.setCreatedBy(user.getUserId());
		notice.setCreatedDate(new java.sql.Timestamp(new java.util.Date().getTime()));
		notice.setLastUpdBy(user.getUserId());
		notice.setLastUpdDate(new java.sql.Timestamp(new java.util.Date().getTime()));
		this.insert("createNotice", notice);
	}

	@Override
	public void delNotice(Notice notice,Users user) {
		this.delete("delNotice", notice);
	}

	@Override
	public void updateNotice(Notice notice, Users user) {
		notice.setLastUpdBy(user.getUserId());
		notice.setLastUpdDate(new java.sql.Timestamp(new java.util.Date().getTime()));
		this.update("updateNotice", notice);
	}

	@Override
	public List<Notice> noticeByUserId(String userId) {
		return this.selectList("getNoticeByUserId", userId);
	}

	@Override
	public PageInfo<Notice> noticePageByUserId(String UserId, int pageSize,
			int pageIndex) {
		return super.findPage("getNoticeByUserId", UserId, pageSize, pageIndex);
	}

	@Override
	public PageInfo<Docs> notice(Users user, Notice notice, int pageSize,
			int pageIndex) {
		return super.findPage("getNoticeDocs", notice,pageSize, pageIndex);
	}

}
